<template>
	<Layout class="p-5 bg-white">
		
		<Form :label-width="80">
            <row>
            
            		<Col span="8">
			<FormItem class="w-100" label="车辆名">
				<input v-model="car.name" placeholder="请输入车辆的名称"/>
			</FormItem>
			<FormItem class="w-100" label="车龄">
				<input v-model="car.carCondition"  placeholder="请输入车龄"/>
				<!-- <Tree 
					:data="allPermissions" show-checkbox multiple></Tree> -->
			</FormItem>
			<FormItem class="w-100" label="表显里程">
				<input v-model="car.mileage" placeholder="请输入表显里程" />	
			</FormItem>
			<FormItem class="w-100" label="排量">
				<input v-model="car.displacement" placeholder="请输入车的排量" />
			</FormItem>
			<FormItem class="w-100" label="变速箱">
				<input v-model="car.transmissionCase" placeholder="请输入变速箱" />				
			</FormItem>
			<FormItem class="w-100" label="车牌归属地">
				<input v-model="car.ownerShip" placeholder="请输入车牌归属地" />				
			</FormItem>
			<FormItem class="w-100" label="车辆颜色">
				<input v-model="car.color" placeholder="请输入车辆颜色" />				
			</FormItem>
			<FormItem class="w-100" label="车型">
				<input v-model="car.type" placeholder="请输入车型" />				
			</FormItem>			
			</Col>
			
		<Col span="8">
			
			<FormItem class="w-100" label="品牌">
				<input v-model="car.brandId" placeholder="请输入车辆品牌" />				
			</FormItem>
			<FormItem class="w-100" label="排放标准">
				<input v-model="car.standard" placeholder="请输入车辆排放标准" />				
			</FormItem>
			<FormItem class="w-100" label="座数">
				<input v-model="car.seats" placeholder="请输入座数" />				
			</FormItem>
			<FormItem class="w-100" label="燃油类型">
				<input v-model="car.energy" placeholder="请输入车辆燃油类型" />				
			</FormItem>
			<FormItem class="w-100" label="驱动类型">
				<input v-model="car.drive" placeholder="请输入驱动类型" />				
			</FormItem>
			<FormItem class="w-100" label="出厂日期">
				 <el-date-picker
				      v-model="car.productionDate"
				      type="datetime"
					  format="yyyy-MM-dd HH:mm:ss"
					  value-format="yyyy-MM-dd HH:mm:ss"
				      placeholder="选择日期时间">
				    </el-date-picker>		
			</FormItem>
			<FormItem class="w-100" label="创建日期">
				<el-date-picker
				     v-model="car.ct"
				     type="datetime"
					 format="yyyy-MM-dd HH:mm:ss"
					 value-format="yyyy-MM-dd HH:mm:ss"
				     placeholder="选择日期时间">
				   </el-date-picker>	
								
			</FormItem>
			<FormItem class="w-100" label="国别">
				<input v-model="car.country" placeholder="请输入车辆国别" />				
			</FormItem>
			<FormItem class="text-right">
				<Button @click="submit" type="primary">提交</Button>
				<Button @click="cancel" class="ml-2">取消</Button>
			</FormItem>
            </Col>
            </row>
		</Form>		

		
	</Layout>
</template>

<script>
	export default {
		data: function() {
			return {
				car: {
					name: "",
					carCondition:null ,
					mileage: null,
					displacement:"",
					transmissionCase:"",
					ownerShip:"",
					color:"",
					productionDate:"",
					brandId:null,
					type:"",
					standard:"",
					seats:null,
					energy:"",
					drive:"",
					imgs:"",
					country:"",
					ct:""					
				}
				
			};
		},
		methods: {
			submit(){
				console.log(this.car.productionDate);
				if (this.$data.car.name.length === 0) {
					this.message.error("车名必须输入");
					return;
				}
				
				if (this.$data.car.carCondition === 0) {
					this.message.error("车龄必须输入");
					return;
				}
				
				if (this.$data.car.mileage === 0) {
					this.message.error("车辆表显里程必须输入");
					return;
				}
				
				if (this.$data.car.brandId === 0) {
					this.message.error("车辆品牌必须输入");
					return;
				}
				let self = this;
				
						this.http.post({
							url: "/car-rental-info/add",
							param: this.$data.car
						}).then(data => {
							self.message.info("新增成功");
							this.$tabs.close();
						});
					},
					cancel: function() {
						this.$tabs.close();
					}
				}
				
			}
			
</script>

<style scoped="scoped">
	div{
		float: left;		
	}
	
	
	
</style>
